//
//  WKDoubiListCell.m
//  WKMaybell
//
//  Created by 何文虎 on 2019/1/3.
//  Copyright © 2019 何文虎. All rights reserved.
//

#import "WKDoubiListCell.h"
#import "WKProgressView.h"

@interface WKDoubiListCell ()
@property(nonatomic,strong)UIView *bgview;
@property(nonatomic,strong)UILabel *titleLb;
@property(nonatomic,strong)UILabel *detailLb;
@property(nonatomic,strong)UILabel *doubiLb;
@property(nonatomic,strong)UILabel *valueLb;
@property(nonatomic,strong)UIButton *statusBtn;
@property(nonatomic,strong)WKProgressView *progressView;
@end

@implementation WKDoubiListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self layoutDoubiListCell];
    }
    return self;
}

- (void)layoutDoubiListCell{

    self.contentView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.bgview];
    [self.bgview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(107);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
    }];
    self.bgview.layer.masksToBounds = YES;
    self.bgview.layer.cornerRadius = 5;
    self.bgview.layer.borderWidth = 1;
    self.bgview.layer.borderColor = LINEBACK_COLOR.CGColor;
    
    [self.bgview addSubview:self.titleLb];
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(15);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-80);
        make.height.mas_equalTo(16);
    }];
    
    [self.bgview addSubview:self.detailLb];
    [self.detailLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLb.mas_bottom).offset(12);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-80);
        make.height.mas_equalTo(12);
    }];
    
    [self.bgview addSubview:self.statusBtn];
    [self.statusBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(23);
        make.right.mas_equalTo(-12);
        make.width.mas_equalTo(66);
        make.height.mas_equalTo(24);
    }];
    self.statusBtn.layer.masksToBounds = YES;
    self.statusBtn.layer.cornerRadius = 12;
    [self.statusBtn addTarget:self action:@selector(statusClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [self.bgview addSubview:self.doubiLb];
    [self.doubiLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.detailLb.mas_bottom).offset(8);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(12);
    }];
    
    [self.bgview addSubview:self.valueLb];
    [self.valueLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-13);
        make.right.mas_equalTo(-12);
        make.width.mas_equalTo(25);
        make.height.mas_equalTo(12);
    }];
    
     [self.bgview addSubview:self.progressView];
    
    _titleLb.text = @"进入-我的页面-分享给好友";
    _detailLb.text = @"转发朋友圈分享美宝App";
    _doubiLb.text = @"痘币 +20";
    _valueLb.text = @"2/3";
    _progressView.playValue = 2;
    _progressView.cacheValue = 3;
    _statusBtn.selected = YES;
}

#pragma mark - 点击状态
- (void)statusClick:(UIButton*)sender{
    sender.selected = !sender.selected;
}

- (UIView*)bgview{
    if (!_bgview) {
        _bgview = [[UIView alloc]init];
    }
    return _bgview;
}

- (UILabel*)titleLb{
    if (!_titleLb) {
        _titleLb = [[UILabel alloc]init];
        _titleLb.textColor = UIColorFromHex(0x3C3C3C);
        _titleLb.font = PFSC_BoldFont(15);
    }
    return _titleLb;
}

- (UILabel*)detailLb{
    if (!_detailLb) {
        _detailLb = [[UILabel alloc]init];
        _detailLb.textColor = UIColorFromHex(0x3C3C3C);
        _detailLb.font = PFSC_MediumFont(12);
    }
    return _detailLb;
}

- (UILabel*)valueLb{
    if (!_valueLb) {
        _valueLb = [[UILabel alloc]init];
        _valueLb.font = PFSC_MediumFont(12);
        _valueLb.textAlignment = NSTextAlignmentRight;
        
    }
    return _valueLb;
}

- (UILabel*)doubiLb{
    if (!_doubiLb) {
        _doubiLb = [[UILabel alloc]init];
        _doubiLb.textColor = UIColorFromHex(0x3C3C3C);
        _doubiLb.font = PFSC_MediumFont(12);
    }
    return _doubiLb;
}

- (UIButton*)statusBtn{
    if (!_statusBtn) {
        _statusBtn.backgroundColor = BACK_COLOR;
        _statusBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_statusBtn setTitle:@"未完成" forState:UIControlStateNormal];
        [_statusBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_statusBtn setTitle:@"已完成" forState:UIControlStateDisabled];
        [_statusBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
    }
    return _statusBtn;
}

- (WKProgressView*)progressView{
    if (!_progressView) {
        _progressView = [[WKProgressView alloc]initWithFrame:CGRectMake(12, 85, ScreenWidth-24-24-30, 6)];
    }
    return _progressView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
